/**
 * @Author: lclangcheng
 * @Date:   2018-08-17 11:23:19
 * @Email:  lclangcheng@gmail.com
 * @Filename: routes.js
 * @Last modified by:   lclangcheng
 * @Last modified time: 2018-09-26 16:11:17
 * @License: jin10
 * @Copyright: jin10
 */
'use strict'

var fs = require('fs')

const _modules = []
const path = process.cwd() + '/router'
const files = fs.readdirSync(path)
files.forEach((filename) => {
  const router = require(path + '/' + filename)
  _modules.push(router)
})

module.exports = (app) => {
  _modules.forEach((module) => {
    if (module && module.routes) {
      app.use(module.middleware())
    }
  })
}
